package net.wwang.blog.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @author WangWei
 * @date 2020/8/14
 */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    //允许基于选择匹配在资源级配置基于网络的安全性
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        //允许druid监控
        http.csrf().ignoringAntMatchers("/druid/*","/swagger-ui.html");
        http.headers().contentTypeOptions().disable();
        http
                //请求管理
                .authorizeRequests()
                .antMatchers("/**").permitAll();
        //允许跨站资源共享
        http.cors().disable();
        //允许跨站请求伪造
        http.csrf().disable();

    }
}
